import Vue from 'vue';
import Vuex from 'vuex';
import CacheStore from './module/CacheStore.js';
import ChatStore from './module/ChatStore.js';
import UserStore from './module/UserStore.js';
import DeviceStore from './module/DeviceStore.js';
import IMessageStore from './module/IMessageStore.js';
import createPersistedState from "vuex-persistedstate";
import { localStorage } from 'mp-storage';

Vue.use(Vuex);

const store = new Vuex.Store({
	modules: {
		chat: ChatStore,
		user: UserStore,
		device: DeviceStore,
		iMessage: IMessageStore,
		cache: CacheStore
	},
	plugins: [
		createPersistedState({
			storage: localStorage,
			reducer(val) {
				return {
					// 指定存储
					// device: val.device,
					user: val.user,
					iMessage: val.iMessage,
					cache: val.cache
					// message: val.message
				}
			}
		})
	]
})

export default store
